home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 212 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: stdc.demon.co.uk!clive
  2. From: clive@stdc.demon.co.uk (Clive D.W. Feather)
  3. Newsgroups: comp.std.c
  4. Subject: Re: How to calculate the Holy Easter.
  5. Date: Sun, 28 Jan 1996 21:44:53 GMT
  6. Organization: Demon Internet Limited (personal account)
  7. Message-ID: <DLwv2u.BBE@stdc.demon.co.uk>
  8. References: <4e5kmh$2g9@leporello.cs.unibo.it> <juggler.822536373@iquest.net>
  9. Reply-To: clive@demon.net
  10. X-NNTP-Posting-Host: stdc.demon.co.uk
  11.  
  12. >> Hi, can anybody send me a C function to calculate the Easter of every year?
  13. >> Thanks in advance,
  14. > This is the algorithm Gauss published in 1800 to calculate Easter-date.
  15.  
  16. [...]
  17.  
  18. The Gauss algorithm fails to handle certain elements of the algorithm,
  19. and, if I recall correctly, gets A.D. 4200 wrong (it is actually April
  20. 20th):
  21.  
  22. >  a := Year mod 19;
  23. >  b := Year mod 4;
  24. >  c := Year mod 7;
  25. >  k := Year div 100;
  26.  
  27. a = 1, b = 0, c = 0, k = 42
  28.  
  29. >  p := k div 3;
  30. >  q := k - k div 4;
  31. >  m := (q - p + 15) mod 30;
  32. >  n := (q + 4) mod 7;
  33. >  d := (19*a + m) mod 30;
  34. >  e := (2*b + 4*c + 6*d + n) mod 7;
  35. >  f := d + e - 9;
  36.  
  37. p = 14, q = 32, m = 3, n = 1, d = 22, e = 0, f = 13
  38.  
  39. >  if f <= 0 then
  40. >    begin
  41. >      Month := 3;
  42. >      Day := 31 + f;
  43. >    end
  44. >  else
  45. >    begin
  46. >      Month := 4;
  47. >      if f = 26 then Day := 19
  48. >      else if (f = 25) and (d = 28) then Day := 18
  49. >      else Day := f;
  50. >    end
  51.  
  52. Gives April 13th, wrong.
  53.  
  54. -- 
  55. Clive D.W. Feather                       | If you lie to the compiler,
  56. cdwf@cityscape.co.uk   (work, preferred) | it will get its revenge.
  57. clive@stdc.demon.co.uk (home)            |   - Henry Spencer
  58.